<%--
  Created by IntelliJ IDEA.
  User: 82387
  Date: 2018/10/11
  Time: 15:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/meta.jsp"%>
<html>
<head>
    <title>工资列表</title>
</head>
<body>
<div class="block_layout block_form" id="wageView">
    <div class="block_title">
        <h3>组合查询</h3>
        <em><a onclick="javascript:HgUi.hideShowSearch(this);" class="slide_up"></a></em>
    </div>
    <div class="block_content">
        <form id="wageViewForm" class="hgform">
            <table cellpadding="0" cellspacing="0" class="table_form">
                <!--普通表单填写表格使用table_form-->
                <colgroup>
                    <col style="width: 120px;"/>
                    <col style="width: 120px;"/>
                    <col style="width: 120px;"/>
                    <col style="width: 120px;"/>
                    <col style="width: 120px;"/>
                    <col style="width: 120px;"/>
                </colgroup>
                <!--表单表格宽度控制使用colgroup，每个col对应下方的一个td，或者th，上下是对齐的-->
                <thead></thead>
                <!--表头-->
                <tfoot>
                <!--表尾，主要放表单按钮-->
                <tr>
                    <th></th>
                    <td colspan="7">
                        <a href="javascript:void(0);" class="a_blue" tag="submit"><em>查询</em></a>
                        <a href="javascript:void(0);" class="a_green" tag="clear"><em>重置</em></a>
                    </td>
                </tr>
                </tfoot>
                <tbody>
                <!--表内容，th是蓝色字体，主要放字段名，td为字段内容-->
                <tr>
                    <th><span>所属部门:</span></th>
                    <td><input name="applyCode" class="easyui-combobox" name="deptId" id="deptId"
                               data-options="prompt: '---请选择---',panelHeight:'auto',valueField:'id',textField:'departName',url:'${ctx}/dept/getConombox'"/></td>
                    <th><span>姓名:</span></th>
                    <td><input name="userName" id="userName"/></td>
                    <th><span>月份:</span></th>
                    <td><input name="sysDate" id="sysDate" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM'})" name="sysDataStr"/></td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
</div>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',border:false"
         style="padding: 0px;height: 410px">
        <table id="wageList" class="easyui-datagrid" fit="true" fitColumns="true"
               url="${ctx}/wage/list" toolbar="#wageList_toolbar" singleSelect="true"
               rownumbers="true" pagination="true" style="height: 500px">
            <thead>
            <tr>
                <th field="sysDate" width="80">日期</th>
                <th field="deptName" width="80">部门</th>
                <th field="userNum" width="80">编号</th>
                <th field="userName" width="80">姓名</th>
                <th field="uesrBasicwage" width="80">基本工资</th>
                <th field="userSalaryscale" width="80">薪级工资</th>
                <th field="userMiles" width="80">里程补贴</th>
                <th field="userMisuse" width="80">误餐补助</th>
                <th field="userOvertimepay" width="80">加班费</th>
                <th field="userOrther1" width="80">其他1</th>
                <th field="userPayablewage" width="80">应发工资</th>
                <th field="userSocialsecurity" width="80">社保费</th>
                <th field="userAccumulation" width="80">公积金</th>
                <th field="userAbsenteeism" width="80">缺勤扣发</th>
                <th field="userIncometax" width="80">所得税</th>
                <th field="userOther2" width="80">其他2</th>
                <th field="userNetpayroll" width="80">实发工资</th>
            </tr>
            </thead>
        </table>
        <div id="openDialog" style="display: none"></div>

        <div id="wageList_toolbar" tag=listen_hotkey>
            <table class="table_form_result">
                <caption>
                    <a href="javascript:void(0);" class="a_btn_blue" tag="autoAdd"><em>一键生成上月工资</em></a>
                    <a href="javascript:void(0);" class="a_btn_blue" tag="add"><em>新增</em></a>
                    <a href="javascript:void(0);" class="a_btn_green" tag="edit"><em>修改</em></a>
                    <a href="javascript:void(0);" class="a_btn_green" tag="bachEdit"><em>批量修改</em></a>
                    <a href="javascript:void(0);" class="a_btn_green" tag="sameEdit"><em>同项设置</em></a>
                    <a href="javascript:void(0);" class="a_btn_red" tag="del"><em>删除</em></a>
                    <a href="javascript:void(0);" class="a_btn_green" tag="deptPrint"><em>部门打印</em></a>
                    <a href="javascript:void(0);" class="a_btn_green" tag="carPrint"><em>车辆使用费打印</em></a>
                </caption>
            </table>
        </div>
    </div>
</div>
<script type="text/javascript">
    $("#wageViewForm").find("[tag=submit]").click(function () {
        var parm = {};
        parm["deptId"] = $("#wageViewForm #deptId").combobox("getValue");
        parm["userName"] = $("#wageViewForm #userName").val();
        parm["sysDate"] = $("#wageViewForm #sysDate").val();
        $("#wageList").datagrid('load',parm);
    });
    $("#wageViewForm").find("[tag=clear]").click(function () {
        $("#wageViewForm").form("clear");
        var parm = {};
        $("#wageList").datagrid('load',parm);
    });
    $("#wageList_toolbar").find("[tag=add]").click(function () {
        new openWindows({
            id:'openDialog',
            title: '新增工资明细',
            width: 700,
            height: 400,
            url: '${ctx}/wage/info'
        });

    });

    $("#wageList_toolbar").find("[tag=edit]").click(function () {
        var row = $("#wageList").datagrid("getSelected");
        if (!row){
            $.messager.alert("提示", "请选择一条记录!", "warning");
            return;
        }
        new openWindows({
            id:'openDialog',
            title: '修改工资明细',
            width: 700,
            height: 400,
            url: '${ctx}/wage/info?id='+row.id
        });
    });
    $("#wageList_toolbar").find("[tag=bachEdit]").click(function () {
        new openWindows({
            id:'openDialog',
            title: '批量修改',
            width: 300,
            height: 250,
            url: '${ctx}/wage/batchEditView'
        });
    });
    $("#wageList_toolbar").find("[tag=sameEdit]").click(function () {
        new openWindows({
            id:'openDialog',
            title: '同项设置',
            width: 300,
            height: 250,
            url: '${ctx}/wage/sameEditView'
        });

    });
    $("#wageList").datagrid({
        //双击事件
        onDblClickRow: function (index, row) {
            $("#wageList_toolbar").find("[tag=edit]").click();
        }
    });

    $("#wageList_toolbar").find("[tag=autoAdd]").click(function () {
        $.messager.confirm('确认', '您确认要生成上月工资记录(已存在上月记录将会被覆盖)？', function (r) {
            if (r) {
                ajaxLoading();
                $.post("${ctx}/wage/initWageForMonth",{},function (data) {
                    ajaxLoadEnd();
                    if(data.success){
                        $.messager.alert('提示','操作成功');
                        $("#wageList").datagrid('reload');
                    }else {
                        $.messager.alert('提示','生成失败');
                    }
                });
            }
        });

    });
    $("#wageList_toolbar").find("[tag=del]").click(function () {
        var row = $("#wageList").datagrid("getSelected");
        if (!row){
            $.messager.alert("提示", "请选择一条记录!", "warning");
            return;
        }
        $.messager.confirm('确认', '您确认要删除该条数据？', function (r) {
            if (r) {
                ajaxLoading();
                $.post("${ctx}/wage/del",{id:row.id},function (data) {
                    ajaxLoadEnd();
                    if(data.success){
                        $.messager.alert('提示','删除成功');
                        $("#wageList").datagrid('reload');
                    }else {
                        $.messager.alert('提示','删除失败');
                    }
                });
            }
        });
    });
    $("#wageList_toolbar").find("[tag=deptPrint]").click(function () {
        new openWindows({
            id:'openDialog',
            title: '部门打印',
            width: 300,
            height: 200,
            url: '${ctx}/wage/toChooseDept'
        });

    });
    $("#wageList_toolbar").find("[tag=carPrint]").click(function () {
        window.open("${ctx}/person/carPayPrint", "_blank");
    });
</script>
</body>
</html>
